package com.hex.liyue.commonmodule.utils;

import com.hex.liyue.LiYueApplication;
import com.hex.liyue.commonmodule.listener.EMLoginListener;
import com.hyphenate.EMCallBack;
import com.hyphenate.chat.EMClient;

/**
 * Created by yukuo on 2016/6/16.
 */
public class EMUtils {
    public static void login(String username, final EMLoginListener eMLoginListener) {
        EMClient.getInstance().login(username, "777777777", new EMCallBack() {//回调
            @Override
            public void onSuccess() {
                LiYueApplication.getMainHandler().post(new Runnable() {
                    @Override
                    public void run() {
                        if (eMLoginListener!=null){
                            eMLoginListener.onSuccess();
                        }

                    }
                });
            }

            @Override
            public void onProgress(int progress, String status) {

            }

            @Override
            public void onError(int code, String message) {
                if (eMLoginListener!=null){
                    eMLoginListener.onFailure();
                }
            }
        });
    }
}
